using EFCoreLib01;
using Microsoft.EntityFrameworkCore;

namespace AspNetCorePrj
{
    public class Program
    {
        public static string ConnectString = @"Server=(localdb)\mssqllocaldb;Database=AspNetCorePrj.EFCoreLib01;Trusted_Connection=True;";
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);

            // Add services to the container.
            builder.Services.AddRazorPages();
            builder.Services.AddControllersWithViews();

            builder.Services.AddDbContext<PersionDbContext>(options => options.UseSqlServer(ConnectString, sqlServerOptions => sqlServerOptions.EnableRetryOnFailure()));
            builder.Services.AddTransient<IUnitOfWorkManager, UnitOfWorkManager>();


            var app = builder.Build();

            // Configure the HTTP request pipeline.
            if (!app.Environment.IsDevelopment())
            {
                app.UseExceptionHandler("/Error");
            }
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();



            app.MapControllerRoute(
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}");



            app.Run();

        }
    }
}
